package com.example.service;

import com.example.entity.HistoryEvents;
import com.example.entity.HistoryPeople;
import com.example.mapper.HistoryEventsMapper;
import com.example.mapper.HistoryPeopleMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
历史人物业务处理
 */
@Service
public class HistoryPeopleService {

    @Resource
    private HistoryPeopleMapper historyPeopleMapper;

    public void add(HistoryPeople historyPeople) {
        historyPeopleMapper.insert(historyPeople);
    }

    public void deleteById(Integer id) {
        historyPeopleMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(HistoryPeople historyPeople) {
        historyPeopleMapper.updateById(historyPeople);
    }

    public HistoryPeople selectById(Integer id) {
        return historyPeopleMapper.selectById(id);
    }

    public List<HistoryPeople> selectAll(HistoryPeople historyPeople) {
        return historyPeopleMapper.selectAll(historyPeople);
    }

    public PageInfo<HistoryPeople> selectPage(HistoryPeople historyPeople, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<HistoryPeople> historyPeopleList = historyPeopleMapper.selectAll(historyPeople);
        return PageInfo.of(historyPeopleList);
    }
}
